package com.kczd.jinlan.adapter.recycleviewadapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.kczd.jinlan.R;
import com.kczd.jinlan.model.Jiaoliu;

import java.util.ArrayList;
import java.util.List;

/**
 * zhangy
 * Created by Administrator on 2017/5/23.
 */

public class PaypriceRecycleViewAdapter  extends RecyclerView.Adapter<PaypriceRecycleViewAdapter.ViewHolder>{

    private Context mContext;
    private List<Jiaoliu> dataList = new ArrayList<>();


    public void addAllData(List<Jiaoliu> dataList) {
        this.dataList.addAll(dataList);
        notifyDataSetChanged();
    }

    public void clearData() {
        this.dataList.clear();
    }

    public PaypriceRecycleViewAdapter(Context context) {
        mContext = context;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView title;
        TextView time;
        TextView status;
        TextView ordernum;
        ImageView icon;

        public ViewHolder(View view) {
            super(view);
            title = (TextView) view.findViewById(R.id.tv_id_title);
            icon = (ImageView) view.findViewById(R.id.iv_id_img);
            ordernum = (TextView) view.findViewById(R.id.tv_id_ordernum);
            time = (TextView) view.findViewById(R.id.tv_id_time);
            status = (TextView) view.findViewById(R.id.tv_id_status);
        }
    }

    @Override
    public PaypriceRecycleViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_payprice, parent, false);
        return new PaypriceRecycleViewAdapter.ViewHolder(v);
    }


    @Override
    public void onBindViewHolder(PaypriceRecycleViewAdapter.ViewHolder holder, final int position) {
        holder.title.setText(dataList.get(position).getTitle());
        holder.ordernum.setText(dataList.get(position).getOrder_num());
        holder.time.setText(dataList.get(position).getTime());
        holder.status.setText(dataList.get(position).getStataus());

    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }

}
